Popular Searches
Popular Course Categories
Popular Courses

Expected Conditions

Waits in Selenium

<div class="selenium-notes">

<h1>Expected Conditions in Selenium</h1>

<p><strong>JustAcademy Selenium Training:</strong> <a href="https://www.justacademy.co/course-detail/selenium-training" target="_blank" rel="noopener noreferrer">JustAcademy Selenium Training Course</a></p>
<p><strong>JustAcademy Demo Registration:</strong> <a href="https://www.justacademy.co/register-for-course-demo" target="_blank" rel="noopener noreferrer">Register for Selenium Course Demo</a></p>

<p><strong>Expected Conditions</strong> are predefined conditions provided by Selenium that are commonly used with explicit waits to synchronize automated test execution with the current state of a web application. Instead of making Selenium wait for a fixed amount of time, Expected Conditions allow the script to wait for a specific condition such as an element becoming visible, clickable, selected, present, invisible, or containing specific text.</p>

<p>Expected Conditions are especially important when testing modern web applications where elements can be loaded or updated asynchronously through JavaScript, AJAX requests, API calls, animations, dynamic DOM changes, and other browser-side operations.</p>

<p>JustAcademy's Selenium curriculum includes waits, synchronization, and dynamic elements, including implicit wait, explicit wait, Fluent Wait, page-load synchronization, handling dynamic elements, and stable test execution strategies. <a href="https://www.justacademy.co/course-detail/selenium-training" target="_blank" rel="noopener noreferrer">Selenium Training Course</a> | <a href="https://www.justacademy.co/register-for-course-demo" target="_blank" rel="noopener noreferrer">Selenium Course Demo</a></p>

<hr>

<h2>1. What are Expected Conditions?</h2>

<p>Expected Conditions are ready-to-use conditions that can be passed to Selenium's explicit wait mechanism. They help the automation script wait until a particular state is achieved before continuing with the next operation.</p>

<pre><code>WebDriverWait wait = new WebDriverWait(driver, Duration.ofSeconds(10));

WebElement username = wait.until(

        ExpectedConditions.visibilityOfElementLocated(By.id("username")));</code></pre>

<p>In this example, Selenium waits until the username element is visible before returning the WebElement.</p>

<hr>

<h2>2. Why are Expected Conditions Required?</h2>

<p>Selenium commands can execute faster than a web application can update its user interface. A page may still be loading, an AJAX request may still be running, a button may still be disabled, or a dynamic element may not yet exist in the DOM.</p>

<p>Without proper synchronization, Selenium tests can fail even when the application is functioning correctly.</p>

<pre><code>Test Starts

   ↓

Open Application

   ↓

Application Loads

   ↓

JavaScript Executes

   ↓

API/AJAX Request

   ↓

DOM Updates

   ↓

Element Becomes Ready

   ↓

Selenium Performs Action</code></pre>

<hr>

<h2>3. Expected Conditions and Explicit Wait</h2>

<p>Expected Conditions are most commonly used with <code>WebDriverWait</code>, which provides explicit waiting for a particular condition.</p>

<pre><code>WebDriverWait wait = new WebDriverWait(driver, Duration.ofSeconds(10));

wait.until(ExpectedConditions.visibilityOfElementLocated(By.id("login")));</code></pre>

<p>The wait checks the specified condition until it succeeds or the maximum timeout is reached.</p>

<hr>

<h2>4. Required Imports</h2>

<pre><code>import java.time.Duration;

import org.openqa.selenium.By;

import org.openqa.selenium.WebDriver;

import org.openqa.selenium.WebElement;

import org.openqa.selenium.Alert;

import org.openqa.selenium.support.ui.ExpectedConditions;

import org.openqa.selenium.support.ui.WebDriverWait;</code></pre>

<hr>

<h2>5. Basic Syntax</h2>

<pre><code>WebDriverWait wait = new WebDriverWait(driver, Duration.ofSeconds(10));

WebElement element = wait.until(

        ExpectedConditions.visibilityOfElementLocated(

                By.id("username")));</code></pre>

<hr>

<h2>6. How Expected Conditions Work</h2>

<pre><code>Create WebDriverWait

        ↓

Set Maximum Timeout

        ↓

Specify Expected Condition

        ↓

Check Condition

        ↓

Condition Satisfied?

     /        \

   Yes         No

   ↓            ↓

Continue    Check Again

                ↓

          Timeout Reached?

             /      \

           No        Yes

           ↓          ↓

        Repeat    TimeoutException</code></pre>

<hr>

<h2>7. ExpectedConditions Class</h2>

<p>Selenium provides the <code>ExpectedConditions</code> class containing commonly used conditions for synchronizing browser automation.</p>

<table border="1" cellpadding="8" cellspacing="0">

<tr><th>Expected Condition</th><th>Purpose</th></tr>

<tr><td>presenceOfElementLocated()</td><td>Waits for an element to be present in the DOM.</td></tr>

<tr><td>visibilityOfElementLocated()</td><td>Waits for an element to be located and visible.</td></tr>

<tr><td>visibilityOf()</td><td>Waits for an existing WebElement to become visible.</td></tr>

<tr><td>elementToBeClickable()</td><td>Waits for an element to be visible and enabled.</td></tr>

<tr><td>invisibilityOfElementLocated()</td><td>Waits for an element to become invisible or unavailable.</td></tr>

<tr><td>textToBePresentInElementLocated()</td><td>Waits for specific text to appear.</td></tr>

<tr><td>textToBePresentInElement()</td><td>Waits for specific text in an existing element.</td></tr>

<tr><td>attributeToBe()</td><td>Waits for an attribute to have a specific value.</td></tr>

<tr><td>attributeContains()</td><td>Waits for an attribute to contain specific text.</td></tr>

<tr><td>elementToBeSelected()</td><td>Waits for an element to become selected.</td></tr>

<tr><td>elementSelectionStateToBe()</td><td>Waits for a selected or unselected state.</td></tr>

<tr><td>alertIsPresent()</td><td>Waits for a JavaScript alert.</td></tr>

<tr><td>frameToBeAvailableAndSwitchToIt()</td><td>Waits for a frame and switches into it.</td></tr>

<tr><td>stalenessOf()</td><td>Waits for an old element to become detached from the DOM.</td></tr>

<tr><td>titleContains()</td><td>Waits for text to appear in the page title.</td></tr>

<tr><td>titleIs()</td><td>Waits for the exact page title.</td></tr>

<tr><td>urlContains()</td><td>Waits for text to appear in the URL.</td></tr>

<tr><td>urlToBe()</td><td>Waits for the URL to exactly match a value.</td></tr>

<tr><td>numberOfWindowsToBe()</td><td>Waits for a specific number of browser windows or tabs.</td></tr>

</table>

<hr>

<h2>8. presenceOfElementLocated()</h2>

<p><code>presenceOfElementLocated()</code> waits until an element is present in the DOM. The element does not necessarily need to be visible.</p>

<pre><code>WebElement element = wait.until(

        ExpectedConditions.presenceOfElementLocated(

                By.id("username")));</code></pre>

<h3>Example</h3>

<pre><code>WebElement searchBox = wait.until(

        ExpectedConditions.presenceOfElementLocated(

                By.id("search")));

 

searchBox.sendKeys("Selenium");</code></pre>

<hr>

<h2>9. Presence vs Visibility</h2>

<table border="1" cellpadding="8" cellspacing="0">

<tr><th>Presence</th><th>Visibility</th></tr>

<tr><td>Element exists in the DOM.</td><td>Element is displayed.</td></tr>

<tr><td>Element may still be hidden.</td><td>Element is rendered and has meaningful dimensions.</td></tr>

<tr><td>Useful when DOM existence is enough.</td><td>Useful before visible interaction.</td></tr>

<tr><td>Does not guarantee user visibility.</td><td>Does not automatically guarantee successful clicking.</td></tr>

</table>

<hr>

<h2>10. visibilityOfElementLocated()</h2>

<p><code>visibilityOfElementLocated()</code> waits until the element can be located and is visible.</p>

<pre><code>WebElement username = wait.until(

        ExpectedConditions.visibilityOfElementLocated(

                By.id("username")));

 

username.sendKeys("admin");</code></pre>

<hr>

<h2>11. visibilityOf()</h2>

<p><code>visibilityOf()</code> is useful when the WebElement has already been located and the test needs to wait until it becomes visible.</p>

<pre><code>WebElement message = driver.findElement(By.id("message"));

 

WebElement visibleMessage = wait.until(

        ExpectedConditions.visibilityOf(message));</code></pre>

<hr>

<h2>12. visibilityOfElementLocated() vs visibilityOf()</h2>

<table border="1" cellpadding="8" cellspacing="0">

<tr><th>Method</th><th>Input</th><th>Purpose</th></tr>

<tr><td>visibilityOfElementLocated()</td><td>By locator</td><td>Locates and waits for visibility.</td></tr>

<tr><td>visibilityOf()</td><td>WebElement</td><td>Waits for an already located element to become visible.</td></tr>

</table>

<hr>

<h2>13. elementToBeClickable()</h2>

<p><code>elementToBeClickable()</code> waits until an element is visible and enabled. It is commonly used before clicking buttons, links, checkboxes, menus, and other interactive controls.</p>

<pre><code>WebElement loginButton = wait.until(

        ExpectedConditions.elementToBeClickable(

                By.id("login")));

 

loginButton.click();</code></pre>

<hr>

<h2>14. What Does Clickable Mean?</h2>

<p>For Selenium's expected condition, an element is considered clickable when it is visible and enabled. This condition does not guarantee that a click will always succeed because another element, overlay, animation, layout change, or dynamic DOM update may still interfere.</p>

<hr>

<h2>15. elementToBeClickable() with WebElement</h2>

<pre><code>WebElement button = driver.findElement(By.id("submit"));

 

WebElement clickableButton = wait.until(

        ExpectedConditions.elementToBeClickable(button));

 

clickableButton.click();</code></pre>

<hr>

<h2>16. invisibilityOfElementLocated()</h2>

<p><code>invisibilityOfElementLocated()</code> is useful when the test needs to wait until a temporary element such as a loader, spinner, overlay, or progress indicator becomes invisible or is no longer present.</p>

<pre><code>wait.until(

        ExpectedConditions.invisibilityOfElementLocated(

                By.id("loader")));</code></pre>

<hr>

<h2>17. Waiting for Loading Spinner</h2>

<pre><code>wait.until(

        ExpectedConditions.invisibilityOfElementLocated(

                By.cssSelector(".loading-spinner")));

 

WebElement dashboard = wait.until(

        ExpectedConditions.visibilityOfElementLocated(

                By.id("dashboard")));</code></pre>

<hr>

<h2>18. textToBePresentInElementLocated()</h2>

<p>This condition waits until the specified text is present inside an element located by the given locator.</p>

<pre><code>wait.until(

        ExpectedConditions.textToBePresentInElementLocated(

                By.id("status"),

                "Completed"));</code></pre>

<hr>

<h2>19. Dynamic Status Example</h2>

<pre><code>wait.until(

        ExpectedConditions.textToBePresentInElementLocated(

                By.id("orderStatus"),

                "Delivered"));

 

System.out.println("Order completed");</code></pre>

<hr>

<h2>20. textToBePresentInElement()</h2>

<p>This condition can be used when the WebElement has already been located.</p>

<pre><code>WebElement message = driver.findElement(By.id("message"));

 

wait.until(

        ExpectedConditions.textToBePresentInElement(

                message,

                "Success"));</code></pre>

<hr>

<h2>21. textToBePresentInElementValue()</h2>

<p>This condition can be used to wait until the value of a form element contains the expected text.</p>

<pre><code>wait.until(

        ExpectedConditions.textToBePresentInElementValue(

                By.id("search"),

                "Selenium"));</code></pre>

<hr>

<h2>22. attributeToBe()</h2>

<p><code>attributeToBe()</code> waits until an element's specified attribute has the expected value.</p>

<pre><code>wait.until(

        ExpectedConditions.attributeToBe(

                By.id("status"),

                "data-state",

                "complete"));</code></pre>

<hr>

<h2>23. attributeContains()</h2>

<p><code>attributeContains()</code> waits until an attribute contains a specified value.</p>

<pre><code>wait.until(

        ExpectedConditions.attributeContains(

                By.id("order"),

                "class",

                "completed"));</code></pre>

<hr>

<h2>24. Waiting for Dynamic CSS Class</h2>

<pre><code>wait.until(

        ExpectedConditions.attributeContains(

                By.id("submit"),

                "class",

                "active"));</code></pre>

<hr>

<h2>25. elementToBeSelected()</h2>

<p><code>elementToBeSelected()</code> waits until an element becomes selected. It is useful for checkboxes, radio buttons, and selectable elements.</p>

<pre><code>wait.until(

        ExpectedConditions.elementToBeSelected(

                By.id("terms")));</code></pre>

<hr>

<h2>26. elementSelectionStateToBe()</h2>

<p><code>elementSelectionStateToBe()</code> waits until an element reaches the specified selected or unselected state.</p>

<pre><code>wait.until(

        ExpectedConditions.elementSelectionStateToBe(

                By.id("terms"),

                true));</code></pre>

<hr>

<h2>27. Waiting for Checkbox Selection</h2>

<pre><code>wait.until(

        ExpectedConditions.elementSelectionStateToBe(

                By.id("terms"),

                true));</code></pre>

<hr>

<h2>28. Waiting for Checkbox to Become Unselected</h2>

<pre><code>wait.until(

        ExpectedConditions.elementSelectionStateToBe(

                By.id("subscribe"),

                false));</code></pre>

<hr>

<h2>29. alertIsPresent()</h2>

<p><code>alertIsPresent()</code> waits until a JavaScript alert is present.</p>

<pre><code>Alert alert = wait.until(

        ExpectedConditions.alertIsPresent());

 

alert.accept();</code></pre>

<hr>

<h2>30. Handling Alert with Expected Condition</h2>

<pre><code>driver.findElement(By.id("delete")).click();

 

Alert alert = wait.until(

        ExpectedConditions.alertIsPresent());

 

System.out.println(alert.getText());

 

alert.accept();</code></pre>

<hr>

<h2>31. Handling Confirmation Alert</h2>

<pre><code>Alert alert = wait.until(

        ExpectedConditions.alertIsPresent());

 

if (alert.getText().contains("Are you sure")) {

    alert.accept();

}</code></pre>

<hr>

<h2>32. frameToBeAvailableAndSwitchToIt()</h2>

<p><code>frameToBeAvailableAndSwitchToIt()</code> waits until a frame becomes available and switches the WebDriver context into that frame.</p>

<pre><code>wait.until(

        ExpectedConditions.frameToBeAvailableAndSwitchToIt(

                By.id("paymentFrame")));

 

driver.findElement(By.id("cardNumber"))

        .sendKeys("1234");</code></pre>

<hr>

<h2>33. Switching Back from Frame</h2>

<pre><code>wait.until(

        ExpectedConditions.frameToBeAvailableAndSwitchToIt(

                By.id("paymentFrame")));

 

driver.findElement(By.id("cardNumber"))

        .sendKeys("1234");

 

driver.switchTo().defaultContent();</code></pre>

<hr>

<h2>34. stalenessOf()</h2>

<p><code>stalenessOf()</code> waits until a previously located WebElement is no longer attached to the current DOM.</p>

<pre><code>WebElement oldElement = driver.findElement(

        By.id("dynamicElement"));

 

driver.findElement(By.id("refresh")).click();

 

wait.until(

        ExpectedConditions.stalenessOf(oldElement));</code></pre>

<hr>

<h2>35. Why stalenessOf() is Useful</h2>

<p>Modern web applications may replace existing DOM elements after an action. The original WebElement can then become stale. Waiting for the old element to become stale can help synchronize the test before locating the newly rendered element.</p>

<hr>

<h2>36. titleContains()</h2>

<p><code>titleContains()</code> waits until the browser page title contains specified text.</p>

<pre><code>wait.until(

        ExpectedConditions.titleContains("Dashboard"));</code></pre>

<hr>

<h2>37. titleIs()</h2>

<p><code>titleIs()</code> waits until the page title exactly matches the expected title.</p>

<pre><code>wait.until(

        ExpectedConditions.titleIs("Dashboard - Home"));</code></pre>

<hr>

<h2>38. urlContains()</h2>

<p><code>urlContains()</code> waits until the current URL contains the specified text.</p>

<pre><code>wait.until(

        ExpectedConditions.urlContains("/dashboard"));</code></pre>

<hr>

<h2>39. urlToBe()</h2>

<p><code>urlToBe()</code> waits until the current URL exactly matches the expected URL.</p>

<pre><code>wait.until(

        ExpectedConditions.urlToBe(

                "https://example.com/dashboard"));</code></pre>

<hr>

<h2>40. urlMatches()</h2>

<p><code>urlMatches()</code> can be used when the URL needs to match a regular expression pattern.</p>

<pre><code>wait.until(

        ExpectedConditions.urlMatches(

                ".*/dashboard.*"));</code></pre>

<hr>

<h2>41. numberOfWindowsToBe()</h2>

<p><code>numberOfWindowsToBe()</code> waits until the browser has the specified number of windows or tabs.</p>

<pre><code>String parentWindow = driver.getWindowHandle();

 

driver.findElement(By.id("openWindow")).click();

 

wait.until(

        ExpectedConditions.numberOfWindowsToBe(2));</code></pre>

<hr>

<h2>42. Switching to New Window</h2>

<pre><code>wait.until(

        ExpectedConditions.numberOfWindowsToBe(2));

 

for (String handle : driver.getWindowHandles()) {

    if (!handle.equals(parentWindow)) {

        driver.switchTo().window(handle);

        break;

    }

}</code></pre>

<hr>

<h2>43. presenceOfAllElementsLocatedBy()</h2>

<p><code>presenceOfAllElementsLocatedBy()</code> waits until matching elements are present in the DOM and returns the collection of matching elements.</p>

<pre><code>List&lt;WebElement&gt; products = wait.until(

        ExpectedConditions.presenceOfAllElementsLocatedBy(

                By.cssSelector(".product")));</code></pre>

<hr>

<h2>44. visibilityOfAllElementsLocatedBy()</h2>

<p><code>visibilityOfAllElementsLocatedBy()</code> waits until all matching elements are visible.</p>

<pre><code>List&lt;WebElement&gt; products = wait.until(

        ExpectedConditions.visibilityOfAllElementsLocatedBy(

                By.cssSelector(".product")));</code></pre>

<hr>

<h2>45. visibilityOfAllElements()</h2>

<p>This condition can be used when a collection of WebElements has already been located and the test needs to wait for their visibility.</p>

<pre><code>List&lt;WebElement&gt; products =

        driver.findElements(By.cssSelector(".product"));

 

wait.until(

        ExpectedConditions.visibilityOfAllElements(products));</code></pre>

<hr>

<h2>46. Expected Conditions for Dynamic Applications</h2>

<p>Expected Conditions are particularly useful when working with dynamic applications where the state of the page changes after user actions or background operations.</p>

<ul>

<li>AJAX requests</li>

<li>API responses</li>

<li>Dynamic tables</li>

<li>Search results</li>

<li>Loading spinners</li>

<li>Modal dialogs</li>

<li>Dynamic dropdowns</li>

<li>Autocomplete suggestions</li>

<li>Dynamic buttons</li>

<li>Changing status messages</li>

<li>Single Page Applications</li>

</ul>

<hr>

<h2>47. Expected Conditions for AJAX</h2>

<pre><code>wait.until(

        ExpectedConditions.visibilityOfElementLocated(

                By.id("ajaxResult")));</code></pre>

<p>Instead of using a fixed delay, the test waits for the UI state that indicates the AJAX operation has produced its result.</p>

<hr>

<h2>48. Expected Conditions for Search Results</h2>

<pre><code>driver.findElement(By.id("search"))

        .sendKeys("Selenium");

 

driver.findElement(By.id("searchButton")).click();

 

List&lt;WebElement&gt; results = wait.until(

        ExpectedConditions.visibilityOfAllElementsLocatedBy(

                By.cssSelector(".search-result")));</code></pre>

<hr>

<h2>49. Expected Conditions for Dynamic Button</h2>

<pre><code>WebElement submit = wait.until(

        ExpectedConditions.elementToBeClickable(

                By.id("submit")));

 

submit.click();</code></pre>

<hr>

<h2>50. Expected Conditions for Loading Spinner</h2>

<pre><code>wait.until(

        ExpectedConditions.invisibilityOfElementLocated(

                By.cssSelector(".spinner")));

 

WebElement result = wait.until(

        ExpectedConditions.visibilityOfElementLocated(

                By.id("result")));</code></pre>

<hr>

<h2>51. Expected Conditions for Modal Dialog</h2>

<pre><code>WebElement modal = wait.until(

        ExpectedConditions.visibilityOfElementLocated(

                By.id("confirmationModal")));

 

WebElement confirm = wait.until(

        ExpectedConditions.elementToBeClickable(

                By.id("confirm")));

 

confirm.click();</code></pre>

<hr>

<h2>52. Expected Conditions for Login</h2>

<pre><code>driver.findElement(By.id("username"))

        .sendKeys("admin");

 

driver.findElement(By.id("password"))

        .sendKeys("admin123");

 

wait.until(

        ExpectedConditions.elementToBeClickable(

                By.id("login"))).click();

 

wait.until(

        ExpectedConditions.visibilityOfElementLocated(

                By.id("dashboard")));</code></pre>

<hr>

<h2>53. Expected Conditions for E-Commerce</h2>

<pre><code>wait.until(

        ExpectedConditions.elementToBeClickable(

                By.id("addToCart"))).click();

 

wait.until(

        ExpectedConditions.attributeContains(

                By.id("cart"),

                "data-count",

                "1"));</code></pre>

<hr>

<h2>54. Expected Conditions for Checkout</h2>

<pre><code>wait.until(

        ExpectedConditions.elementToBeClickable(

                By.id("checkout"))).click();

 

wait.until(

        ExpectedConditions.visibilityOfElementLocated(

                By.id("paymentPage")));</code></pre>

<hr>

<h2>55. Expected Conditions for Registration</h2>

<pre><code>wait.until(

        ExpectedConditions.elementToBeClickable(

                By.id("register"))).click();

 

wait.until(

        ExpectedConditions.visibilityOfElementLocated(

                By.id("registrationSuccess")));</code></pre>

<hr>

<h2>56. Expected Conditions with TestNG</h2>

<pre><code>import org.testng.Assert;

import org.testng.annotations.Test;

 

@Test

public void verifyDashboard() {

    WebElement dashboard = wait.until(

            ExpectedConditions.visibilityOfElementLocated(

                    By.id("dashboard")));

 

    Assert.assertTrue(dashboard.isDisplayed());

}</code></pre>

<hr>

<h2>57. Expected Conditions in Page Object Model</h2>

<pre><code>public class LoginPage {

    private WebDriver driver;

    private WebDriverWait wait;

 

    private By username = By.id("username");

    private By password = By.id("password");

    private By loginButton = By.id("login");

    private By dashboard = By.id("dashboard");

 

    public LoginPage(WebDriver driver) {

        this.driver = driver;

        this.wait = new WebDriverWait(

                driver,

                Duration.ofSeconds(10));

    }

 

    public void login(String user, String pass) {

        wait.until(

                ExpectedConditions.visibilityOfElementLocated(

                        username)).sendKeys(user);

 

        wait.until(

                ExpectedConditions.visibilityOfElementLocated(

                        password)).sendKeys(pass);

 

        wait.until(

                ExpectedConditions.elementToBeClickable(

                        loginButton)).click();

    }

 

    public boolean isDashboardDisplayed() {

        return wait.until(

                ExpectedConditions.visibilityOfElementLocated(

                        dashboard)).isDisplayed();

    }

}</code></pre>

<hr>

<h2>58. Reusable Wait Utility</h2>

<pre><code>public class WaitUtils {

    private WebDriverWait wait;

 

    public WaitUtils(WebDriver driver) {

        wait = new WebDriverWait(

                driver,

                Duration.ofSeconds(10));

    }

 

    public WebElement waitForVisible(By locator) {

        return wait.until(

                ExpectedConditions.visibilityOfElementLocated(

                        locator));

    }

 

    public WebElement waitForClickable(By locator) {

        return wait.until(

                ExpectedConditions.elementToBeClickable(

                        locator));

    }

 

    public void waitForInvisible(By locator) {

        wait.until(

                ExpectedConditions.invisibilityOfElementLocated(

                        locator));

    }

}</code></pre>

<hr>

<h2>59. Using Wait Utility</h2>

<pre><code>WaitUtils waitUtils = new WaitUtils(driver);

 

WebElement username =

        waitUtils.waitForVisible(By.id("username"));

 

username.sendKeys("admin");

 

waitUtils.waitForClickable(

        By.id("login")).click();</code></pre>

<hr>

<h2>60. Custom Expected Condition with Lambda</h2>

<p>When Selenium's predefined conditions do not exactly match the application's state, a custom lambda condition can be used with <code>wait.until()</code>.</p>

<pre><code>Boolean completed = wait.until(driver -&gt; {

    WebElement status = driver.findElement(By.id("status"));

    return "Completed".equals(status.getText());

});</code></pre>

<hr>

<h2>61. Waiting for an Element to Become Enabled</h2>

<pre><code>Boolean enabled = wait.until(driver -&gt; {

    return driver.findElement(By.id("submit")).isEnabled();

});</code></pre>

<p>If the requirement is both visibility and enabled state before clicking, <code>elementToBeClickable()</code> is often a more appropriate condition.</p>

<hr>

<h2>62. Waiting for a Specific Number of Elements</h2>

<pre><code>List&lt;WebElement&gt; products = wait.until(driver -&gt; {

    List&lt;WebElement&gt; elements =

            driver.findElements(By.cssSelector(".product"));

    return elements.size() &gt;= 5 ? elements : null;

});</code></pre>

<hr>

<h2>63. Expected Conditions and TimeoutException</h2>

<p>If the required condition is not satisfied before the configured timeout expires, Selenium's explicit wait fails with a <code>TimeoutException</code>.</p>

<pre><code>try {

    wait.until(

            ExpectedConditions.visibilityOfElementLocated(

                    By.id("result")));

} catch (TimeoutException e) {

    System.out.println(

            "Element did not become visible");

    throw e;

}</code></pre>

<hr>

<h2>64. Expected Conditions and StaleElementReferenceException</h2>

<p>Dynamic applications can replace DOM elements. If a previously stored WebElement is replaced, the reference can become stale.</p>

<pre><code>WebElement oldElement = driver.findElement(

        By.id("dynamic"));

 

driver.findElement(By.id("refresh")).click();

 

wait.until(

        ExpectedConditions.stalenessOf(oldElement));

 

WebElement newElement = wait.until(

        ExpectedConditions.visibilityOfElementLocated(

                By.id("dynamic")));</code></pre>

<hr>

<h2>65. Expected Conditions vs Thread.sleep()</h2>

<table border="1" cellpadding="8" cellspacing="0">

<tr><th>Expected Conditions</th><th>Thread.sleep()</th></tr>

<tr><td>Condition-based synchronization.</td><td>Fixed delay.</td></tr>

<tr><td>Checks application state.</td><td>Does not check application state.</td></tr>

<tr><td>Can continue as soon as the condition succeeds.</td><td>Always waits the complete duration.</td></tr>

<tr><td>Suitable for dynamic applications.</td><td>Not a good general synchronization strategy.</td></tr>

<tr><td>Provides reusable conditions.</td><td>Provides no application-specific condition.</td></tr>

</table>

<hr>

<h2>66. Expected Conditions vs Implicit Wait</h2>

<table border="1" cellpadding="8" cellspacing="0">

<tr><th>Feature</th><th>Implicit Wait</th><th>Expected Conditions</th></tr>

<tr><td>Scope</td><td>Element lookup.</td><td>Specific application state.</td></tr>

<tr><td>Visibility</td><td>No specific visibility condition.</td><td>Supported.</td></tr>

<tr><td>Clickability</td><td>No.</td><td>Supported.</td></tr>

<tr><td>Alerts</td><td>No.</td><td>Supported.</td></tr>

<tr><td>Frames</td><td>No.</td><td>Supported.</td></tr>

<tr><td>Text</td><td>No.</td><td>Supported.</td></tr>

<tr><td>Attributes</td><td>No.</td><td>Supported.</td></tr>

</table>

<hr>

<h2>67. Expected Conditions vs Fluent Wait</h2>

<table border="1" cellpadding="8" cellspacing="0">

<tr><th>Feature</th><th>Expected Conditions</th><th>Fluent Wait</th></tr>

<tr><td>Purpose</td><td>Predefined synchronization conditions.</td><td>Flexible waiting mechanism.</td></tr>

<tr><td>Timeout</td><td>Configured through WebDriverWait.</td><td>Configurable.</td></tr>

<tr><td>Polling</td><td>Handled by the wait implementation.</td><td>Polling interval can be customized.</td></tr>

<tr><td>Custom Conditions</td><td>Can be combined with custom lambda conditions.</td><td>Designed for custom waiting behavior.</td></tr>

<tr><td>Exception Handling</td><td>Depends on wait configuration.</td><td>Selected exceptions can be configured.</td></tr>

</table>

<hr>

<h2>68. Presence vs Visibility vs Clickable</h2>

<table border="1" cellpadding="8" cellspacing="0">

<tr><th>Condition</th><th>Meaning</th><th>Typical Use</th></tr>

<tr><td>Presence</td><td>Element exists in DOM.</td><td>DOM existence.</td></tr>

<tr><td>Visibility</td><td>Element is displayed.</td><td>Visible UI interaction.</td></tr>

<tr><td>Clickable</td><td>Element is visible and enabled.</td><td>Click operations.</td></tr>

</table>

<hr>

<h2>69. Choosing the Correct Expected Condition</h2>

<table border="1" cellpadding="8" cellspacing="0">

<tr><th>Requirement</th><th>Condition</th></tr>

<tr><td>Element exists</td><td>presenceOfElementLocated()</td></tr>

<tr><td>Element is visible</td><td>visibilityOfElementLocated()</td></tr>

<tr><td>Button is ready to click</td><td>elementToBeClickable()</td></tr>

<tr><td>Loader disappears</td><td>invisibilityOfElementLocated()</td></tr>

<tr><td>Text appears</td><td>textToBePresentInElementLocated()</td></tr>

<tr><td>Attribute changes</td><td>attributeToBe() or attributeContains()</td></tr>

<tr><td>Checkbox is selected</td><td>elementToBeSelected()</td></tr>

<tr><td>Alert appears</td><td>alertIsPresent()</td></tr>

<tr><td>Frame becomes available</td><td>frameToBeAvailableAndSwitchToIt()</td></tr>

<tr><td>Old element is replaced</td><td>stalenessOf()</td></tr>

<tr><td>Title changes</td><td>titleContains() or titleIs()</td></tr>

<tr><td>URL changes</td><td>urlContains() or urlToBe()</td></tr>

<tr><td>New tab opens</td><td>numberOfWindowsToBe()</td></tr>

</table>

<hr>

<h2>70. Expected Conditions for AJAX Workflow</h2>

<pre><code>Click Search

   ↓

AJAX Request

   ↓

Loading Spinner

   ↓

Wait for Spinner to Disappear

   ↓

Wait for Search Results

   ↓

Verify Results

   ↓

Continue Test</code></pre>

<hr>

<h2>71. Expected Conditions for Login Workflow</h2>

<pre><code>Open Login Page

   ↓

Wait for Username

   ↓

Enter Username

   ↓

Wait for Password

   ↓

Enter Password

   ↓

Wait for Login Button

   ↓

Click Login

   ↓

Wait for Dashboard

   ↓

Verify Dashboard</code></pre>

<hr>

<h2>72. Expected Conditions for E-Commerce Workflow</h2>

<pre><code>Open Product Page

   ↓

Wait for Product

   ↓

Wait for Add to Cart

   ↓

Click Add to Cart

   ↓

Wait for Cart Update

   ↓

Wait for Checkout

   ↓

Click Checkout

   ↓

Wait for Payment Page

   ↓

Verify Order</code></pre>

<hr>

<h2>73. Expected Conditions with Dynamic Dropdown</h2>

<pre><code>WebElement dropdown = wait.until(

        ExpectedConditions.elementToBeClickable(

                By.id("country")));

 

dropdown.click();

 

WebElement option = wait.until(

        ExpectedConditions.elementToBeClickable(

                By.xpath("//option[text()='India']")));

 

option.click();</code></pre>

<hr>

<h2>74. Expected Conditions with Autocomplete</h2>

<pre><code>driver.findElement(By.id("city"))

        .sendKeys("Mum");

 

WebElement suggestion = wait.until(

        ExpectedConditions.elementToBeClickable(

                By.xpath("//li[contains(text(),'Mumbai')]")));

 

suggestion.click();</code></pre>

<hr>

<h2>75. Expected Conditions with Dynamic Table</h2>

<pre><code>List&lt;WebElement&gt; rows = wait.until(

        ExpectedConditions.visibilityOfAllElementsLocatedBy(

                By.cssSelector("table tbody tr")));

 

for (WebElement row : rows) {

    System.out.println(row.getText());

}</code></pre>

<hr>

<h2>76. Expected Conditions with Modal</h2>

<pre><code>WebElement modal = wait.until(

        ExpectedConditions.visibilityOfElementLocated(

                By.id("modal")));

 

WebElement close = wait.until(

        ExpectedConditions.elementToBeClickable(

                By.id("closeModal")));

 

close.click();

 

wait.until(

        ExpectedConditions.invisibilityOfElementLocated(

                By.id("modal")));</code></pre>

<hr>

<h2>77. Expected Conditions with Navigation</h2>

<pre><code>driver.findElement(By.id("profile")).click();

 

wait.until(

        ExpectedConditions.urlContains("/profile"));

 

wait.until(

        ExpectedConditions.visibilityOfElementLocated(

                By.id("profilePage")));</code></pre>

<hr>

<h2>78. Expected Conditions with Multiple Windows</h2>

<pre><code>String parent = driver.getWindowHandle();

 

driver.findElement(By.id("open")).click();

 

wait.until(

        ExpectedConditions.numberOfWindowsToBe(2));

 

for (String handle : driver.getWindowHandles()) {

    if (!handle.equals(parent)) {

        driver.switchTo().window(handle);

        break;

    }

}</code></pre>

<hr>

<h2>79. Expected Conditions with Alerts</h2>

<pre><code>driver.findElement(By.id("delete")).click();

 

Alert alert = wait.until(

        ExpectedConditions.alertIsPresent());

 

System.out.println(alert.getText());

alert.accept();</code></pre>

<hr>

<h2>80. Expected Conditions with Frames</h2>

<pre><code>wait.until(

        ExpectedConditions.frameToBeAvailableAndSwitchToIt(

                By.id("paymentFrame")));

 

driver.findElement(By.id("cardNumber"))

        .sendKeys("123456");

 

driver.switchTo().defaultContent();</code></pre>

<hr>

<h2>81. Expected Conditions with XPath</h2>

<pre><code>WebElement button = wait.until(

        ExpectedConditions.visibilityOfElementLocated(

                By.xpath("//button[@id='login']")));

 

button.click();</code></pre>

<hr>

<h2>82. Expected Conditions with CSS Selector</h2>

<pre><code>WebElement button = wait.until(

        ExpectedConditions.elementToBeClickable(

                By.cssSelector("#login")));

 

button.click();</code></pre>

<hr>

<h2>83. Expected Conditions with ID</h2>

<pre><code>WebElement username = wait.until(

        ExpectedConditions.visibilityOfElementLocated(

                By.id("username")));</code></pre>

<hr>

<h2>84. Common Mistake: Using Presence When Visibility is Required</h2>

<p>If the test needs to interact with a visible element, DOM presence alone may not be sufficient.</p>

<pre><code>wait.until(

        ExpectedConditions.presenceOfElementLocated(

                By.id("login")));</code></pre>

<p>When visibility is required, use:</p>

<pre><code>wait.until(

        ExpectedConditions.visibilityOfElementLocated(

                By.id("login")));</code></pre>

<hr>

<h2>85. Common Mistake: Using Visibility When a Click is Required</h2>

<p>Visibility does not check whether an element is enabled. For a click operation, <code>elementToBeClickable()</code> can be more appropriate.</p>

<pre><code>wait.until(

        ExpectedConditions.elementToBeClickable(

                By.id("submit"))).click();</code></pre>

<hr>

<h2>86. Common Mistake: Using Thread.sleep()</h2>

<pre><code>Thread.sleep(5000);

driver.findElement(By.id("result")).click();</code></pre>

<p>A condition-based approach is generally more suitable:</p>

<pre><code>wait.until(

        ExpectedConditions.elementToBeClickable(

                By.id("result"))).click();</code></pre>

<hr>

<h2>87. Common Mistake: Very Long Timeout</h2>

<p>Extremely long timeouts can make failed tests slow to diagnose. Timeout values should be realistic for the application's expected response time and the test environment.</p>

<hr>

<h2>88. Common Mistake: Very Short Timeout</h2>

<p>A very short timeout can produce false failures when the application normally requires more time because of network latency, server processing, or browser performance.</p>

<hr>

<h2>89. Common Mistake: Waiting for the Wrong Condition</h2>

<p>A test may fail when the selected condition does not represent the actual application state.</p>

<pre><code>Need the element in DOM?

→ presenceOfElementLocated()

 

Need the element visible?

→ visibilityOfElementLocated()

 

Need the element ready for click?

→ elementToBeClickable()

 

Need the loader gone?

→ invisibilityOfElementLocated()</code></pre>

<hr>

<h2>90. Common Mistake: Unstable Locators</h2>

<p>Expected Conditions cannot fix an incorrect or unstable locator. Stable IDs, data attributes, reliable CSS selectors, and carefully designed XPath expressions should be preferred.</p>

<hr>

<h2>91. Best Practice: Use the Correct Condition</h2>

<p>Always determine the exact state required by the test before selecting an Expected Condition.</p>

<pre><code>DOM Presence

    ↓

presenceOfElementLocated()

 

Visibility

    ↓

visibilityOfElementLocated()

 

Clickable State

    ↓

elementToBeClickable()

 

Disappearance

    ↓

invisibilityOfElementLocated()

 

Text State

    ↓

textToBePresentInElementLocated()

 

Attribute State

    ↓

attributeToBe() / attributeContains()</code></pre>

<hr>

<h2>92. Best Practice: Use Stable Locators</h2>

<pre><code>By loginButton =

        By.cssSelector("[data-testid='login-button']");

 

wait.until(

        ExpectedConditions.elementToBeClickable(

                loginButton)).click();</code></pre>

<hr>

<h2>93. Best Practice: Keep Waits Reusable</h2>

<p>In large automation frameworks, reusable wait utilities reduce duplicated synchronization code and make the framework easier to maintain.</p>

<hr>

<h2>94. Best Practice: Use Page Object Model</h2>

<p>Synchronization logic can be maintained inside Page Object methods so that test cases focus on business workflows and validations.</p>

<hr>

<h2>95. Best Practice: Wait for Real Application State</h2>

<p>Instead of waiting for an arbitrary number of seconds, wait for the actual condition that indicates the application is ready.</p>

<ul>

<li>Wait for a button to become clickable.</li>

<li>Wait for a result to appear.</li>

<li>Wait for a loader to disappear.</li>

<li>Wait for text to change.</li>

<li>Wait for a modal to become visible.</li>

<li>Wait for an attribute to change.</li>

<li>Wait for a new window to open.</li>

<li>Wait for a frame to become available.</li>

</ul>

<hr>

<h2>96. Best Practice: Avoid Unnecessary Waits</h2>

<p>Do not add explicit waits before every Selenium command. Use synchronization where the application has asynchronous or dynamic behavior that requires it.</p>

<hr>

<h2>97. Best Practice: Use Realistic Timeout Values</h2>

<p>Timeouts should provide enough time for expected application behavior without unnecessarily delaying failed tests.</p>

<hr>

<h2>98. Expected Conditions Quick Reference</h2>

<table border="1" cellpadding="8" cellspacing="0">

<tr><th>Condition</th><th>Purpose</th></tr>

<tr><td>presenceOfElementLocated()</td><td>Wait for DOM presence.</td></tr>

<tr><td>visibilityOfElementLocated()</td><td>Wait for visible element.</td></tr>

<tr><td>visibilityOf()</td><td>Wait for an existing element to become visible.</td></tr>

<tr><td>elementToBeClickable()</td><td>Wait for visible and enabled element.</td></tr>

<tr><td>invisibilityOfElementLocated()</td><td>Wait for element to disappear or become invisible.</td></tr>

<tr><td>textToBePresentInElementLocated()</td><td>Wait for specific text.</td></tr>

<tr><td>textToBePresentInElement()</td><td>Wait for text in an existing element.</td></tr>

<tr><td>attributeToBe()</td><td>Wait for exact attribute value.</td></tr>

<tr><td>attributeContains()</td><td>Wait for partial attribute value.</td></tr>

<tr><td>elementToBeSelected()</td><td>Wait for selected element.</td></tr>

<tr><td>elementSelectionStateToBe()</td><td>Wait for selected/unselected state.</td></tr>

<tr><td>alertIsPresent()</td><td>Wait for JavaScript alert.</td></tr>

<tr><td>frameToBeAvailableAndSwitchToIt()</td><td>Wait for frame and switch into it.</td></tr>

<tr><td>stalenessOf()</td><td>Wait for old element to become stale.</td></tr>

<tr><td>titleContains()</td><td>Wait for title text.</td></tr>

<tr><td>titleIs()</td><td>Wait for exact title.</td></tr>

<tr><td>urlContains()</td><td>Wait for URL text.</td></tr>

<tr><td>urlToBe()</td><td>Wait for exact URL.</td></tr>

<tr><td>numberOfWindowsToBe()</td><td>Wait for required window count.</td></tr>

</table>

<hr>

<h2>99. Interview Question: What are Expected Conditions?</h2>

<p><strong>Answer:</strong> Expected Conditions are predefined Selenium conditions used with explicit waits to synchronize test execution with specific application states such as visibility, presence, clickability, text, attributes, alerts, frames, windows, titles, URLs, and selection.</p>

<hr>

<h2>100. Interview Question: Why are Expected Conditions Used?</h2>

<p><strong>Answer:</strong> They are used to synchronize automation scripts with dynamic web applications and reduce failures caused by timing differences between Selenium commands and application state changes.</p>

<hr>

<h2>101. Interview Question: What is presenceOfElementLocated()?</h2>

<p><strong>Answer:</strong> It waits until an element is present in the DOM. It does not require the element to be visible.</p>

<hr>

<h2>102. Interview Question: What is visibilityOfElementLocated()?</h2>

<p><strong>Answer:</strong> It waits until an element is located and is visible on the page.</p>

<hr>

<h2>103. Interview Question: What is elementToBeClickable()?</h2>

<p><strong>Answer:</strong> It waits until an element is visible and enabled, making it suitable for many click operations.</p>

<hr>

<h2>104. Interview Question: Does elementToBeClickable() Guarantee a Successful Click?</h2>

<p><strong>Answer:</strong> No. Overlays, animations, layout changes, stale elements, or other application behavior can still interfere with an actual click.</p>

<hr>

<h2>105. Interview Question: What is invisibilityOfElementLocated()?</h2>

<p><strong>Answer:</strong> It waits until an element becomes invisible or is no longer present according to the condition's behavior.</p>

<hr>

<h2>106. Interview Question: What is alertIsPresent()?</h2>

<p><strong>Answer:</strong> It waits until a JavaScript alert is present and returns the Alert object.</p>

<hr>

<h2>107. Interview Question: What is stalenessOf()?</h2>

<p><strong>Answer:</strong> It waits until a previously located WebElement is no longer attached to the current DOM.</p>

<hr>

<h2>108. Interview Question: What is frameToBeAvailableAndSwitchToIt()?</h2>

<p><strong>Answer:</strong> It waits for a frame to become available and automatically switches the WebDriver context into that frame.</p>

<hr>

<h2>109. Interview Question: Can Expected Conditions Handle Dynamic Elements?</h2>

<p><strong>Answer:</strong> Yes. Conditions such as presence, visibility, clickability, text, attribute changes, selection, and invisibility are useful for dynamic elements.</p>

<hr>

<h2>110. Interview Question: Can Expected Conditions Be Used with XPath?</h2>

<p><strong>Answer:</strong> Yes. Expected Conditions can be used with XPath through <code>By.xpath()</code>.</p>

<pre><code>wait.until(

        ExpectedConditions.visibilityOfElementLocated(

                By.xpath("//button[@id='login']")));</code></pre>

<hr>

<h2>111. Interview Question: Can Expected Conditions Be Used with CSS Selectors?</h2>

<p><strong>Answer:</strong> Yes. CSS selectors can be passed through <code>By.cssSelector()</code>.</p>

<pre><code>wait.until(

        ExpectedConditions.elementToBeClickable(

                By.cssSelector("#login")));</code></pre>

<hr>

<h2>112. Interview Question: What Happens When an Expected Condition Times Out?</h2>

<p><strong>Answer:</strong> If the condition is not satisfied within the configured timeout, the explicit wait fails with a <code>TimeoutException</code>.</p>

<hr>

<h2>113. Practical Project Using Expected Conditions</h2>

<p>A Selenium e-commerce automation project can use Expected Conditions throughout the complete workflow.</p>

<ol>

<li>Launch the browser.</li>

<li>Open the application.</li>

<li>Wait for the login form.</li>

<li>Enter username and password.</li>

<li>Wait for the login button to become clickable.</li>

<li>Click Login.</li>

<li>Wait for the dashboard.</li>

<li>Search for a product.</li>

<li>Wait for search results.</li>

<li>Select the product.</li>

<li>Wait for product details.</li>

<li>Add the product to the cart.</li>

<li>Wait for the cart count to update.</li>

<li>Wait for checkout.</li>

<li>Complete checkout.</li>

<li>Wait for order confirmation.</li>

<li>Verify order status.</li>

</ol>

<hr>

<h2>114. Practical Project Flow</h2>

<pre><code>Launch Browser

   ↓

Open Application

   ↓

Wait for Login Form

   ↓

Enter Credentials

   ↓

Wait for Login Button

   ↓

Click Login

   ↓

Wait for Dashboard

   ↓

Search Product

   ↓

Wait for Search Results

   ↓

Select Product

   ↓

Wait for Product Page

   ↓

Add to Cart

   ↓

Wait for Cart Update

   ↓

Wait for Checkout

   ↓

Complete Checkout

   ↓

Wait for Confirmation

   ↓

Validate Order</code></pre>

<hr>

<h2>115. Advantages of Expected Conditions</h2>

<ul>

<li>Provides condition-based synchronization.</li>

<li>Reduces dependency on fixed delays.</li>

<li>Improves handling of dynamic web applications.</li>

<li>Provides reusable predefined conditions.</li>

<li>Supports visibility and presence checks.</li>

<li>Supports clickability checks.</li>

<li>Supports text and attribute conditions.</li>

<li>Supports alerts and frames.</li>

<li>Supports windows and tabs.</li>

<li>Supports selection states.</li>

<li>Can be combined with custom lambda conditions.</li>

<li>Works well with Page Object Model frameworks.</li>

</ul>

<hr>

<h2>116. Limitations of Expected Conditions</h2>

<ul>

<li>The wrong condition can still cause synchronization failures.</li>

<li>Very short timeouts can cause false failures.</li>

<li>Very long timeouts can slow test execution.</li>

<li>Expected Conditions cannot fix incorrect locators.</li>

<li>Expected Conditions cannot fix application defects.</li>

<li>Clickable does not guarantee that an overlay will not intercept a click.</li>

<li>Complex application-specific states may require custom conditions.</li>

<li>Unnecessary waits can increase execution time.</li>

</ul>

<hr>

<h2>117. Expected Conditions Checklist</h2>

<ul>

<li>Use <code>presenceOfElementLocated()</code> when DOM presence is sufficient.</li>

<li>Use <code>visibilityOfElementLocated()</code> when visibility is required.</li>

<li>Use <code>elementToBeClickable()</code> before many click operations.</li>

<li>Use <code>invisibilityOfElementLocated()</code> for loaders and temporary overlays.</li>

<li>Use text conditions for dynamic status messages.</li>

<li>Use attribute conditions for dynamic application state represented through attributes.</li>

<li>Use <code>alertIsPresent()</code> for JavaScript alerts.</li>

<li>Use frame conditions for dynamic iframes.</li>

<li>Use window conditions for dynamic tabs and windows.</li>

<li>Use <code>stalenessOf()</code> when an old DOM element is replaced.</li>

<li>Use realistic timeout values.</li>

<li>Use stable locators.</li>

<li>Avoid unnecessary <code>Thread.sleep()</code>.</li>

<li>Keep wait logic reusable.</li>

<li>Choose conditions according to the actual application state.</li>

</ul>

<hr>

<h2>118. Final Summary</h2>

<p><strong>Expected Conditions</strong> are an important part of Selenium synchronization and explicit waits. They allow automation scripts to wait for specific application states instead of relying on arbitrary fixed delays.</p>

<p>The most commonly used conditions include <code>presenceOfElementLocated()</code>, <code>visibilityOfElementLocated()</code>, <code>visibilityOf()</code>, <code>elementToBeClickable()</code>, <code>invisibilityOfElementLocated()</code>, <code>textToBePresentInElementLocated()</code>, <code>attributeToBe()</code>, <code>attributeContains()</code>, <code>elementToBeSelected()</code>, <code>alertIsPresent()</code>, <code>frameToBeAvailableAndSwitchToIt()</code>, <code>stalenessOf()</code>, <code>titleContains()</code>, <code>urlContains()</code>, and <code>numberOfWindowsToBe()</code>.</p>

<p>The key to effective Selenium synchronization is selecting the condition that represents the actual state required by the test. Presence, visibility, clickability, selection, text, attributes, alerts, frames, URLs, and windows are different states and should be handled with the appropriate Expected Condition.</p>

<hr>

<h2>119. Selenium Training Resource</h2>

<p>Learn Selenium WebDriver, Java automation, locators, WebElements, waits, synchronization, dynamic elements, TestNG, Page Object Model, framework development, and real-world automation testing through the <a href="https://www.justacademy.co/course-detail/selenium-training" target="_blank" rel="noopener noreferrer">Selenium Training Course</a>.</p>

<p>For a course demonstration, visit the <a href="https://www.justacademy.co/register-for-course-demo" target="_blank" rel="noopener noreferrer">Selenium Course Demo</a>.</p>

</div>

Previous Next
whatsapp